package com.lineage.server.command.executor;

import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.L1Teleport;
import com.lineage.server.serverpackets.S_PacketBoxGm;
import com.lineage.server.serverpackets.S_ServerMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import com.lineage.server.world.World;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class L1ToPC1 implements L1CommandExecutor {
  private static final Log _log = LogFactory.getLog(L1ToPC2.class);
  
  public static L1CommandExecutor getInstance() {
    return new L1ToPC1();
  }
  
  public void execute(L1PcInstance pc, String cmdName, String arg) {
    try {
      L1PcInstance target = World.get().getPlayer(arg);
      if (target != null) {
        pc.set_showId(target.get_showId());
        L1Teleport.teleport(pc, target.getX(), target.getY(), target.getMapId(), 5, false);
        pc.sendPackets((ServerBasePacket)new S_ServerMessage(166, "移动座标至指定人物身边: " + arg));
      } else {
        int mode = 1;
        pc.sendPackets((ServerBasePacket)new S_PacketBoxGm(pc, 1));
      } 
    } catch (Exception e) {
      _log.error("错误的GM指令格式: " + getClass().getSimpleName() + " 执行的GM:" + pc.getName());
      pc.sendPackets((ServerBasePacket)new S_ServerMessage(261));
    } 
  }
}
